package com.yn.service.zy.model.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.yn.common.constants.Constants;
import com.yn.common.model.zy.TInspectionItemDO;
import com.yn.common.model.zy.TInspectionRegionPriceDO;
import com.yn.common.utils.BeanUtils;
import com.yn.common.utils.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.ObjectUtils;

import java.time.LocalDateTime;

/**
 * @ClassName: TInspectionItemDTO
 * @Description:
 * @Author: lxp
 * @Date: 2025/5/7 11:35
 **/
@Data
@ApiModel("检查项出参")
public class TInspectionItemDTO {
    @ApiModelProperty("检查项价格区域主键id")
    private Integer itemPriceId;

    @ApiModelProperty("检查项主键id")
    private Integer itemId;

    @ApiModelProperty("检查项名称")
    private String inspectionItemName;

    @ApiModelProperty("检查类型(特色检查/普通检查)字典")
    private Integer inspectionItemType;

    @ApiModelProperty("单位(次/小时)")
    private String unit;

    @ApiModelProperty("检查项介绍")
    private String inspectionItemIntro;

    @ApiModelProperty("优惠金额")
    private Integer couponPrice;

    @ApiModelProperty("单价")
    private Integer unitPrice;

    @ApiModelProperty("区域")
    private String regionCode;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = Constants.DATE_FORMAT)
    private LocalDateTime createTime;

    public static TInspectionItemDTO transform(TInspectionItemDO tInspectionItem) {
        if (ObjectUtils.isEmpty(tInspectionItem)) {
            return null;
        }

        TInspectionItemDTO tInspectionItemDTO = BeanUtils.copyProperties(tInspectionItem, TInspectionItemDTO.class);

        tInspectionItemDTO.setItemId(tInspectionItem.getId());

        return tInspectionItemDTO;
    }

    public static TInspectionItemDTO transform(TInspectionRegionPriceDO tInspectionRegionPriceDO) {
        if (ObjectUtils.isEmpty(tInspectionRegionPriceDO)) {
            return null;
        }

        TInspectionItemDTO tInspectionItemDTO = BeanUtils.copyProperties(tInspectionRegionPriceDO, TInspectionItemDTO.class);

        tInspectionItemDTO.setItemId(tInspectionRegionPriceDO.getInspectionItemId());
        tInspectionItemDTO.setItemPriceId(tInspectionRegionPriceDO.getId());

        return tInspectionItemDTO;
    }
}
